Attribute VB_Name = "mTextBoxs"
'-----------------------------------------------------------------
'             PT DC Hub @ Direct Connect P2P Network
'-----------------------------------------------------------------
'       Developer: Carlos.DF (fLaSh) - Portugal
'          E-mail: carlosferreiracarlos@hotmail.com
' Project started: 10 - September - 2006
'         License: GNU General Public License.
'-----------------------------------------------------------------
'       Thanks to developers and contributores of SDCH/DDCH
'         The Left Hand, ButterflySoul, HaArD and Selyb
'  TheNOP, RollTheDice, JDommi, GhOstFaCE, ArchaicLight and TUFF
'-----------------------------------------------------------------
Option Explicit

Private Declare Function SetWindowLong Lib "user32" Alias _
   "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
   ByVal dwNewLong As Long) As Long
 
Private Declare Function CallWindowProc Lib "user32" _
   Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
   ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, _
   ByVal lParam As Long) As Long

Private Const GWL_WNDPROC = (-4)

Private Const WM_CONTEXTMENU = &H7B

Global lpPrevWndProc As Long
Global gHW As Long

Public Sub DelPopUpMenu()
1:    Dim i As Integer
2:      On Error GoTo Err
  
4:    For i = 0 To frmHub.txtVSl.count - 1
5:        On Error Resume Next
6:        gHW = frmHub.txtVSl(i).hwnd
7:        If Err.Number Then
8:           Err.Clear
9:        Else
10:          Hook
11:       End If
12:   Next i
  
14:   Exit Sub
15:
Err:
16:   HandleError Err.Number, Err.Description, Erl & "|" & "mTextBoxs.DelPopUpMenu()"
End Sub
Private Sub Hook()
1:   On Error GoTo Err
2:   lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
                                    AddressOf gWindowProc)
4:   Exit Sub
5:
Err:
6:   HandleError Err.Number, Err.Description, Erl & "|" & "mTextBoxs.Hook()"
End Sub

Private Sub Unhook()
1:   Dim temp As Long
2:   temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Private Function gWindowProc(ByVal hwnd As Long, ByVal Msg As Long, _
                 ByVal wParam As Long, ByVal lParam As Long) As Long
2: On Error GoTo Err

4:     If Msg = WM_CONTEXTMENU Then
        'Debug.Print "Intercepted WM_CONTEXTMENU at " & Now
6:        gWindowProc = True
7:     Else ' Send all other messages to the default message handler
8:        gWindowProc = CallWindowProc(lpPrevWndProc, hwnd, Msg, wParam, lParam)
9:     End If
     
11:   Exit Function
12:
Err:
13:   HandleError Err.Number, Err.Description, Erl & "|" & "mTextBoxs.gWindowProc()"
End Function
